//
//  ContactsDateBase.h
//  SIPphone
//
//  Created by wrt on 13-11-27.
//  Copyright (c) 2013年 wrtsoft. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <sqlite3.h>

//联系人的宏定义
#define CONTACTSTABLE_NAME @"contactsTable"
#define CONTACTS_USERNAME @"contactsUserName"
#define CONTACTS_DISPLAYNAME @"contactsDisPlayName"
#define CONTACTS_MARKNAME @"contactsMarkName"
#define CONTACTS_IPPORT @"contactsIpPort"
#define CONTACTS_ONLIENSTATUS @"contactsStatus"
#define CONTACTS_ISFRIEND @"contactsIsFriend"

@interface ContactsDateBase : NSObject
{
    sqlite3 *db;
}

//用户名数组
@property (strong, nonatomic) NSMutableArray *userNameArray;
//昵称数组
@property (strong, nonatomic) NSMutableArray *displayNameArray;
//备注的数组
@property (strong, nonatomic) NSMutableArray *markNameArray;
//域名的数组
@property (strong, nonatomic) NSMutableArray *ipPortArray;
//在线状态的数组
@property (strong, nonatomic) NSMutableArray *onlineStatusArray;
//是否是好友的数组
@property (strong, nonatomic) NSMutableArray *isFriendArray;

//定义表名的属性
@property (strong, nonatomic) NSString *tableNameForUser;


//单例初始化方法
+ (ContactsDateBase *)shareContactsDataBase;

//创建数据库
- (void)creatDB;
//读取数据库
- (void)readDB;
//保存数据库
- (void)saveFriendIntoDBWithUserName:(NSString *)userName andMarkName:(NSString *)markName andIp:(NSString *)ip;
//保存数据库(带昵称情况下)
- (void)saveFriendIntoDBWithUserName:(NSString *)userName andMarkName:(NSString *)markName andIp:(NSString *)ip andDisplayName:(NSString *)displayName;
//数据库删除操作
- (void)deleteContactsBDWithUserName:(NSString *)userName andIpPort:(NSString *)ip;
//刷新数据库操作(改状态)
- (void)updateDBWithUserName:(NSString *)userName andIp:(NSString *)ip andStatus:(NSString *)status;
//刷新数据库操作(更新昵称)
- (void)updateDBWithUserName:(NSString *)userName andIp:(NSString *)ip andStatus:(NSString *)status andDisplayName:(NSString *)displayname;
//刷新数据库操作(修改备注名字)
- (void)updateDBForMarkNameWithUserName:(NSString *)userName andIp:(NSString *)ip andNewMarkName:(NSString *)markName;
//保存数据库（接收好友时）
- (void)saveAcceptFriendIntoDBWithUserName:(NSString *)userName andMarkName:(NSString *)markName andIp:(NSString *)ip;
//切换表名
- (void)changeTableName:(NSString *)userName;
//获取是否为好友的
- (int)isExistAndIsFriendWith:(NSString *)userName andip:(NSString *)ip;
@end
